'''
Description: description
Author: 
LastEditors: M
'''
import os ,json
from compoments.config import PIKER_DIR,exp_config
from compoments.utils import errormsg
setting_p = os.path.join(PIKER_DIR,exp_config)

def try_load_params(fp):
    if not os.path.exists(fp):
        errormsg("参数配置文件不存","请生成参数配置文件:",emphasis=fp)
        exit(-1)
    try:
        params = json.load(open(setting_p,encoding='utf-8'))
        return params
    except Exception as e:
        errormsg("参数配置文件加载错误,检查内容格式是否正确",emphasis=f"{fp}\n\t{str(e)}")
        exit(-1)
        
def load_params():
    return try_load_params(setting_p)
